package com.cwf.quality.common.enums;

public enum DataCheckFilterEnum {
    VALUE_RANGE_CHECK("VALUE_RANGE_CHECK",
            "com.cwf.quality.common.strategy.filter.ValueRangeCheckFilter",
            "SELECT COUNT(*) AS over_range_count FROM {table} WHERE {column} NOT BETWEEN {min} AND {max}"),

    VALUE_LENGTH_CHECK("VALUE_LENGTH_CHECK",
            "com.cwf.quality.common.strategy.filter.ValueLengthCheckFilter",
            "SELECT {column},LENGTH(CAST({column} AS VARCHAR)) AS illegal_length FROM {table} WHERE LENGTH(CAST({column} AS VARCHAR)) != {lengthValue}"),

    VALUE_ENUM_RANGE_CHECK("VALUE_ENUM_RANGE_SQL",
            "com.cwf.quality.common.strategy.filter.ValueEnumRangeCheckFilter",
            "SELECT {column},COUNT(*) AS over_enum_count FROM {table} WHERE {column} NOT IN ({enumValues}) GROUP BY {column}"),

    VALUE_CODE_TABLE_CHECK("VALUE_CODE_TABLE_CHECK",
            "com.cwf.quality.common.strategy.filter.ValueCodeTableCheckFilter",
            "SELECT {column},COUNT(*) AS not_in_code_table_count FROM {table} WHERE {column} NOT IN ( SELECT DISTINCT {codeTableColumn} FROM {codeTable}) GROUP BY {column}"),

    VALUE_PREFIX_CHECK("VALUE_PREFIX_CHECK",
            "com.cwf.quality.common.strategy.filter.ValuePrefixCheckFilter",
            "SELECT {column},COUNT(*) AS not_prefix_count FROM {table} WHERE {column} NOT LIKE concat ( '{prefix}', '%' ) GROUP BY {column}"),
    ;


    private String type;
    private String className;
    private String sql;

    DataCheckFilterEnum(String type, String className, String sql) {
        this.type = type;
        this.className = className;
        this.sql = sql;
    }

    public String getType() {
        return type;
    }

    public String getClassName() {
        return className;
    }

    public String getSql() {
        return sql;
    }
}


